package com.gxa.autoparts.portal.service.impl;

import com.gxa.autoparts.core.pojo.GoodsType;
import com.gxa.autoparts.portal.mapper.GoodsTypeMapper;
import com.gxa.autoparts.portal.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author ：looker
 * @date ：Created in 2022/1/8 16:15
 */
@Service
public class GoodsTypeServiceImpl implements GoodsTypeService {

    @Autowired
    GoodsTypeMapper goodsTypeMapper;

    @Override
    public List<GoodsType> getTopLevel() {
        Example example = new Example(GoodsType.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("pid",0);
        List<GoodsType> goodsTypes = goodsTypeMapper.selectByExample(example);
        return goodsTypes;
    }

    @Override
    public List<GoodsType> getSonLevel(Long id) {
        Example example = new Example(GoodsType.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("pid",id);
        List<GoodsType> goodsTypes = goodsTypeMapper.selectByExample(example);
        return goodsTypes;
    }
}
